#include <stddef.h>
#include <stdio.h>

#ifndef _SYM_TUI_

#define _SYM_TUI_

typedef unsigned short WORD;

struct Console {
	WORD h, w;
};

inline void initConsole(struct Console*, const char*);
// initConsole(&obj, title)
inline void clear(struct Console*);
// clear(&obj)
inline void getConsoleSize(WORD*, WORD*);
// getConsoleSize(&width, &height)
inline void putchar(WORD, WORD, char, struct Console*);
// putchar(x, y, char, &obj)
inline void putcharWithoutChk(WORD, WORD, char);
// putcharWithoutChk(x, y, char)
inline void puts(WORD, WORD, WORD, WORD, const char*, struct Console*);
// puts(x, y, w, h, str, &obj)
inline void resetTitle(const char*);
// resetTitle(title)
inline void setUnicode(void);
inline void disableScl(void);

inline WORD maxWORD(WORD, WORD);
inline WORD minWORD(WORD, WORD);

enum OS_type {
    OS_windows,
    OS_linux,
    OS_unix,
    OS_dos
};

#ifdef _WIN32 || WIN32
#define SYM_TUI_OS OS_windows
#include "tui_win.h"
#endif

#ifdef linux || _linux
#define SYM_TUI_OS OS_linux
#include "tui_unix.h"
#endif

#ifdef unix || _unix
#define SYM_TUI_OS OS_unix
#include "tui_unix.h"
#endif

// #else
// #define SYM_TUI_OS OS_dos
// #include "tui_dos.h"
// #endif

inline void initConsole(struct Console* cptr, const char* title) {
	if(cptr == NULL)	return;
	getConsoleSize(&(cptr->w), &(cptr->h));
	clear(cptr);
	resetTitle(title);
	setUnicode();
	disableScl();
}
inline WORD maxWORD(WORD x, WORD y) {
	return (x<y)?(y):(x);
}
inline WORD minWORD(WORD x, WORD y) {
	return (x>y)?(y):(x);
}
#endif
